//
//  GetNewsCVModel.m
//  HiCar
//
//  Created by huachun on 2019/3/29.
//  Copyright © 2019 丁一. All rights reserved.
//

#import "GetNewsCVModel.h"
#import "HJonesNetting.h"
#import "ChatModel.h"

@implementation GetNewsCVModel

- (instancetype)init:(id)responseObject{
    if (self = [super init]) {
        
        NSMutableArray *linarray = [NSMutableArray new];
        
        [HJonesNetting JonesNetting_POST:responseObject
                                  andURL:App_Chat_GetNew
                              andtimeout:20.0
                                finished:^(NSError * _Nonnull error, NSDictionary * _Nonnull resultDict) {
                                    if (error) {
                                        [SVProgressHUD showErrorWithStatus:@"网络加载失败"];
                                        [self.delegate Succes:0 array:linarray];
                                    }else{
                                        if ([[resultDict objectForKey:@"Code"] longLongValue]==1000) {
                                            
                                            if ([[resultDict objectForKey:@"UserArray"] isKindOfClass:[NSArray class]]) {
                                                if ([[resultDict objectForKey:@"UserArray"] count]>0) {
                                                    for (NSDictionary *dic in [resultDict objectForKey:@"UserArray"]) {
                                                        ChatModel *Model =[ChatModel new];
                                                        Model.Chat_id=[dic objectForKey:@"chat_id"];
                                                        Model.Chat_type=[dic objectForKey:@"chat_type"];
                                                        Model.Chat_info=[dic objectForKey:@"chat_info"];
                                                        Model.Chat_date=[dic objectForKey:@"chat_date"];
                                                        Model.User_id=[dic objectForKey:@"userid"];
                                                        Model.User_name=[dic objectForKey:@"name"];
                                                        Model.User_logo=[dic objectForKey:@"logo"];
                                                        Model.sex=[dic objectForKey:@"sex"];
                                                        Model.briday=[dic objectForKey:@"briday"];
                                                        Model.IsRead=@"0";
//                                                        Model.Chat_type = @"6";
                                                        [linarray addObject:Model];
                                                    }
                                                }
                                            }
                                            
                                            [self.delegate Succes:1 array:linarray];
                                            
                                        }else{
                                            [SVProgressHUD showErrorWithStatus:[resultDict objectForKey:@"Message"]];
                                            [self.delegate Succes:0 array:linarray];
                                        }
                                    }
                                }
                              passmanger:^(NSURLSessionDataTask * _Nonnull manger) {
                                  
                              }
                             andprogress:^(NSProgress * _Nonnull CProgress) {
                                 
                             }];
        
    }
    return self;
}

@end
